package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysBaseData;
import com.ruoyi.system.service.ISysBaseDataService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 特情信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-21
 */
@Controller
@RequestMapping("/system/data")
public class SysBaseDataController extends BaseController
{
    private String prefix = "system/data";

    @Autowired
    private ISysBaseDataService sysBaseDataService;

    @RequiresPermissions("system:data:view")
    @GetMapping()
    public String data()
    {
        return prefix + "/data";
    }

    /**
     * 查询特情信息列表
     */
    @RequiresPermissions("system:data:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysBaseData sysBaseData)
    {
        startPage();
        List<SysBaseData> list = sysBaseDataService.selectSysBaseDataList(sysBaseData);
        return getDataTable(list);
    }

    /**
     * 导出特情信息列表
     */
    @RequiresPermissions("system:data:export")
    @Log(title = "特情信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysBaseData sysBaseData)
    {
        List<SysBaseData> list = sysBaseDataService.selectSysBaseDataList(sysBaseData);
        ExcelUtil<SysBaseData> util = new ExcelUtil<SysBaseData>(SysBaseData.class);
        return util.exportExcel(list, "特情信息数据");
    }

    /**
     * 新增特情信息
     */
    @RequiresPermissions("system:data:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存特情信息
     */
    @RequiresPermissions("system:data:add")
    @Log(title = "特情信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysBaseData sysBaseData)
    {
        return toAjax(sysBaseDataService.insertSysBaseData(sysBaseData));
    }

    /**
     * 修改特情信息
     */
    @RequiresPermissions("system:data:edit")
    @GetMapping("/edit/{dataId}")
    public String edit(@PathVariable("dataId") Long dataId, ModelMap mmap)
    {
        SysBaseData sysBaseData = sysBaseDataService.selectSysBaseDataByDataId(dataId);
        mmap.put("sysBaseData", sysBaseData);
        return prefix + "/edit";
    }

    /**
     * 修改保存特情信息
     */
    @RequiresPermissions("system:data:edit")
    @Log(title = "特情信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysBaseData sysBaseData)
    {
        return toAjax(sysBaseDataService.updateSysBaseData(sysBaseData));
    }

    /**
     * 删除特情信息
     */
    @RequiresPermissions("system:data:remove")
    @Log(title = "特情信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysBaseDataService.deleteSysBaseDataByDataIds(ids));
    }
}
